unit UFrmreforcos;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, Wwdbigrd, Wwdbgrid, Mask, Buttons, ExtCtrls, RXCtrls, StdCtrls,
  DBCtrls;

type
  TFrmreforcos = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    RxLabel1: TRxLabel;
    Image1: TImage;
    Panel1: TPanel;
    btnAdicionar: TSpeedButton;
    btnRetornar: TSpeedButton;
    btnGravar: TSpeedButton;
    GroupBox2: TGroupBox;
    SpeedButton2: TSpeedButton;
    Label5: TLabel;
    Label6: TLabel;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    wwDBGrid1: TwwDBGrid;
    MaskEdit3: TMaskEdit;
    MaskEdit4: TMaskEdit;
    procedure btnRetornarClick(Sender: TObject);
    procedure btnAdicionarClick(Sender: TObject);
    procedure btnGravarClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frmreforcos: TFrmreforcos;

implementation
uses modulo;
{$R *.DFM}

procedure TFrmreforcos.btnRetornarClick(Sender: TObject);
begin
   close;
end;

procedure TFrmreforcos.btnAdicionarClick(Sender: TObject);
begin
   DMEscola.Qreforcos.Append;
   MaskEdit3.Text :=  DateToStr(Date);
   MaskEdit4.TExt := TimeToStr(Time);
   DBEdit3.SetFocus;
end;

procedure TFrmreforcos.btnGravarClick(Sender: TObject);
begin
   DMEscola.QreforcosData.Value := StrToDate(MaskEdit3.Text);
   DMEscola.QreforcosHora.Value := StrToTime(MAskEdit4.Text);
   DMEscola.Qreforcos.Post;
   DMEscola.Qreforcos.Edit;
end;

procedure TFrmreforcos.FormShow(Sender: TObject);
begin
   MaskEdit3.Text :=  DateToStr(Date);
   MaskEdit4.TExt := TimeToStr(Time);
   MaskEdit1.Text := DateToStr(Date);
   MaskEdit2.Text := DateToStr(Date);
   DBEdit3.SetFocus;
   DMEscola.Qreforcos.Append;
end;

procedure TFrmreforcos.SpeedButton2Click(Sender: TObject);
var
  obs : string;
begin
   obs := '';
   DMEscola.Qreforcos.close;
   DMEscola.Qreforcos.SQL.Clear;
   DMEscola.Qreforcos.SQL.Add('Select * From reforcos');
   DMEscola.Qreforcos.SQL.Add('Where data >= :d1 and');
   DMEscola.Qreforcos.SQL.Add('data <= :d2');
   DMEscola.Qreforcos.ParamByName('d1').AsDate := StrToDate(MaskEdit1.text);
   DMEscola.Qreforcos.ParamByName('d2').AsDate := StrToDate(MaskEdit2.text);
   DMEscola.Qreforcos.open;
   obs := DMEscola.QreforcosObs.Value;
   if obs <> '' then
      wwDBGrid1.Visible := true
   else
      ShowMessage('Não foram entradas nenhum suprimento para o intervalo de datas, tente novamente!');
end;

procedure TFrmreforcos.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
   Action := CaFree;
end;

end.
